package com.sinodata.bsm.center.service.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.sinodata.bsm.center.bean.Condition;
import com.sinodata.bsm.center.bean.Page;
import com.sinodata.bsm.center.dao.impl.DimensionDaoImpl;
import com.sinodata.bsm.common.vo.Dimension;
import com.sinodata.bsm.common.vo.DimensionType;

@Service
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public class DimensionService {
    @Autowired
    private DimensionDaoImpl dimensionDaoImpl;

    /**
     * 根据条件查询总数
     */
    public int getTotal(Condition condition) {
        return dimensionDaoImpl.getTotal(condition);
    }

    /**
     *新增
     */
    @Transactional(propagation = Propagation.REQUIRED)
    public void add(Dimension dimension) {
        dimensionDaoImpl.save(dimension);
    }

    /**
     * 分页获取某个维度类型下的维度
     */
    public Page<Dimension> findByPage(Page<Dimension> page, Condition condition) {
        return dimensionDaoImpl.findByPage(page, condition);
    }

    /**
     * 批量删除维度根据维度类型
     * 
     * @param ids
     */
    @Transactional(propagation = Propagation.REQUIRED)
    public void deleteDimensionByTypeid(Long[] typeids) {
        dimensionDaoImpl.batchDeleteByTypeId(typeids);
    }

    /**
     * 删除维度
     * @param ids
     */
    @Transactional(propagation = Propagation.REQUIRED)
    public void deleteDimension(Long[] ids) {
        dimensionDaoImpl.batchDelete(ids);
    }

    /**
     * 修改维度
     * @param dimension
     */
    @Transactional(propagation = Propagation.REQUIRED)
    public void update(Dimension dimension) {
        dimensionDaoImpl.update(dimension);
    }

}
